//
//  MyTakeOrderDetailRequireCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/1/27.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "MyTakeOrderDetailRequireCell.h"

@interface MyTakeOrderDetailRequireCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *title1Lab;
@property (nonatomic, strong) UILabel *content1Lab;
@property (nonatomic, strong) UILabel *title2Lab;
@property (nonatomic, strong) UILabel *content2Lab;
@property (nonatomic, strong) UILabel *title3Lab;
@property (nonatomic, strong) UILabel *content3Lab;
@property (nonatomic, strong) UILabel *title4Lab;
@property (nonatomic, strong) UILabel *content4Lab;

@end

@implementation MyTakeOrderDetailRequireCell

+ (instancetype)MyTakeOrderDetailRequireCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"MyTakeOrderDetailRequireCell";
    MyTakeOrderDetailRequireCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[MyTakeOrderDetailRequireCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = Color_backgroundColor;
        
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xffffff);
        self.bgView.layer.cornerRadius = 6;
        [self.contentView addSubview:self.bgView];
        
        self.titleLab = [UILabel new];
        self.titleLab.font = BoldFontOfSize(18);
        self.titleLab.textColor = HexColor(0x2B2C44);
        self.titleLab.text = @"运输要求";
        [self.bgView addSubview:self.titleLab];
        
        self.title1Lab = [UILabel new];
        self.title1Lab.textColor = HexColor(0x9C9DB3);
        self.title1Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.title1Lab];
        
        self.content1Lab = [UILabel new];
        self.content1Lab.textColor = HexColor(0x2B2C44);
        self.content1Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.content1Lab];
        
        self.title2Lab = [UILabel new];
        self.title2Lab.textColor = HexColor(0x9C9DB3);
        self.title2Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.title2Lab];
        
        self.content2Lab = [UILabel new];
        self.content2Lab.textColor = HexColor(0x2B2C44);
        self.content2Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.content2Lab];
        
        self.title3Lab = [UILabel new];
        self.title3Lab.textColor = HexColor(0x9C9DB3);
        self.title3Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.title3Lab];
        
        self.content3Lab = [UILabel new];
        self.content3Lab.textColor = HexColor(0x2B2C44);
        self.content3Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.content3Lab];
        
        self.title4Lab = [UILabel new];
        self.title4Lab.textColor = HexColor(0x9C9DB3);
        self.title4Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.title4Lab];
        
        self.content4Lab = [UILabel new];
        self.content4Lab.textColor = HexColor(0x2B2C44);
        self.content4Lab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.content4Lab];
    }
    return self;
}

-(void)setModel:(MyTakeOrderDetailMainModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 15;
    self.bgView.nim_top = 0;
    self.bgView.nim_width = ScreenW - 30;
    
    self.titleLab.frame = CGRectMake(15, 15, self.bgView.nim_width - 30, 19);
    
    self.bgView.nim_height = 110;
    
    self.title1Lab.text = @"服务方式：";
    [self.title1Lab sizeToFit];
    self.title1Lab.nim_left = self.titleLab.nim_left;
    self.title1Lab.nim_top = (self.bgView.nim_height - self.titleLab.nim_bottom - 2 * self.title1Lab.nim_height - 5) * 0.5 + self.titleLab.nim_bottom;
    
    self.title2Lab.text = @"运输方式：";
    [self.title2Lab sizeToFit];
    self.title2Lab.nim_left = self.bgView.nim_width * 0.5;
    self.title2Lab.nim_top = self.title1Lab.nim_top;
    
    self.title3Lab.text = @"车辆要求：";
    [self.title3Lab sizeToFit];
    self.title3Lab.nim_left = self.title1Lab.nim_left;
    self.title3Lab.nim_top = self.title1Lab.nim_bottom + 5;
    
    self.title4Lab.text = @"结算方式：";
    [self.title4Lab sizeToFit];
    self.title4Lab.nim_left = self.title2Lab.nim_left;
    self.title4Lab.nim_top = self.title3Lab.nim_top;
    
    self.content1Lab.frame = CGRectMake(self.title1Lab.nim_right, self.title1Lab.nim_top, self.title2Lab.nim_left - self.title1Lab.nim_right, self.title1Lab.nim_height);
    self.content2Lab.frame = CGRectMake(self.title2Lab.nim_right, self.title2Lab.nim_top, self.bgView.nim_width - 15 - self.title2Lab.nim_right, self.title2Lab.nim_height);
    self.content3Lab.frame = CGRectMake(self.title3Lab.nim_right, self.title3Lab.nim_top, self.title4Lab.nim_left - self.title3Lab.nim_right, self.title3Lab.nim_height);
    self.content4Lab.frame = CGRectMake(self.title4Lab.nim_right, self.title4Lab.nim_top, self.bgView.nim_width - 15 - self.title4Lab.nim_right, self.title4Lab.nim_height);
    
    self.content1Lab.text = self.model.delivery;
    self.content2Lab.text = self.model.transport;
    self.content3Lab.text = self.model.needCar;
    self.content4Lab.text = self.model.settleSty;
    
    self.height = self.bgView.nim_bottom;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
